home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-9.10-netbook-remix-PL.iso / casper / filesystem.squashfs / etc / init.d / saned < prev    next >
Text File  |  2009-10-14  |  2KB  |  96 lines

  1. #! /bin/sh
  2. #
  3. ### BEGIN INIT INFO
  4. # Provides:          saned
  5. # Required-Start:    $syslog $local_fs
  6. # Required-Stop:     $syslog $local_fs
  7. # Should-Start:      dbus avahi
  8. # Should-Stop:       dbus avahi
  9. # Default-Start:     2 3 4 5
  10. # Default-Stop:      1
  11. # Short-Description: SANE network scanner server
  12. # Description:       saned makes local scanners available over the
  13. #                    network.
  14. ### END INIT INFO
  15.  
  16. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  17. DAEMON=/usr/sbin/saned
  18. NAME=saned
  19. DESC="SANE network scanner server"
  20.  
  21. test -x $DAEMON || exit 0
  22.  
  23. RUN=no
  24. RUN_AS_USER=saned
  25.  
  26. # Include saned defaults if available
  27. if [ -f /etc/default/saned ] ; then
  28.     . /etc/default/saned
  29. fi
  30.  
  31. if [ "x$RUN" != "xyes" ] ; then
  32.     exit 0
  33. fi
  34.  
  35. DAEMON_OPTS="-a $RUN_AS_USER"
  36.  
  37. set -e
  38.  
  39. case "$1" in
  40.   start)
  41.     echo -n "Starting $DESC: "
  42.     start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
  43.         --exec $DAEMON -- $DAEMON_OPTS
  44.     echo "$NAME."
  45.     ;;
  46.   stop)
  47.     echo -n "Stopping $DESC: "
  48.     start-stop-daemon --stop --oknodo --quiet --pidfile /var/run/$NAME.pid \
  49.         --exec $DAEMON
  50.     echo "$NAME."
  51.     ;;
  52.   force-reload)
  53.     # check whether $DAEMON is running. If so, restart
  54.     start-stop-daemon --stop --test --quiet --pidfile \
  55.         /var/run/$NAME.pid --exec $DAEMON \
  56.     && $0 restart \
  57.     || exit 0
  58.     ;;
  59.   restart)
  60.     echo -n "Restarting $DESC: "
  61.     start-stop-daemon --stop --quiet --pidfile \
  62.         /var/run/$NAME.pid --exec $DAEMON
  63.     sleep 1
  64.     start-stop-daemon --start --quiet --pidfile \
  65.         /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
  66.     echo "$NAME."
  67.     ;;
  68.   status)
  69.     if [ -s /var/run/$NAME.pid ]; then
  70.             RUNNING=$(cat /var/run/$NAME.pid)
  71.             if [ -d /proc/$RUNNING ]; then
  72.                 if [ $(readlink /proc/$RUNNING/exe) = $DAEMON ]; then
  73.                     echo "$NAME is running."
  74.                     exit 0
  75.                 fi
  76.             fi
  77.  
  78.             # No such PID, or executables don't match
  79.             echo "$NAME is not running, but pidfile existed."
  80.             rm /var/run/$NAME.pid
  81.             exit 1
  82.         else
  83.             rm -f /var/run/$NAME.pid
  84.             echo "$NAME not running."
  85.             exit 1
  86.         fi
  87.     ;;
  88.   *)
  89.     N=/etc/init.d/$NAME
  90.     echo "Usage: $N {start|stop|restart|force-reload}" >&2
  91.     exit 1
  92.     ;;
  93. esac
  94.  
  95. exit 0
  96.